package com.yq.homework.day21;

import java.awt.*;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/22 15:20
 * "peter piper picked a peck of pickled peppers"
 * 统计这段绕口令有多少个以p开头的单词
 * 提示:借助split(" ")方法分隔成字符串数组 , startsWith("p")判断是否是p开头
 */
public class Demo01 {
    public static void main(String[] args) {
        String s = "peter piper picked a peck of pickled peppers";
        String[] s1 = s.split(" ");
        int count =0;
        for (int i = 0; i < s1.length; i++) {
            if (s1[i].startsWith("p")){
                count++;
            }
        }
        System.out.println("p开头的一共有"+ count);
    }
}
